package dice.sinanya.tools.getinfo;

import dice.sinanya.entity.EntityRoleLock;

import java.util.HashMap;

import static dice.sinanya.system.RoleInfoCache.ROLE_LOCK;

public class RoleLock {
    public static String getRoleLockName(String qqId, String groupId, String roleName) {
        if (!"0".equals(groupId)) {
            HashMap<EntityRoleLock, String> tmp = ROLE_LOCK;
            EntityRoleLock tmp2 = new EntityRoleLock(qqId, groupId);
            return ROLE_LOCK.getOrDefault(tmp2, roleName);
        }
        return roleName;
    }

    public static String getRoleLockName(long qqId, String groupId, String roleName) {
        if (!"0".equals(groupId)) {
            return ROLE_LOCK.getOrDefault(new EntityRoleLock(String.valueOf(qqId), groupId), roleName);
        }
        return roleName;
    }

    public static boolean checkRoleLockName(String qqId, String groupId, boolean hasChoose) {
        if (!"0".equals(groupId) && ROLE_LOCK.containsKey(new EntityRoleLock(qqId, groupId))) {
            return true;
        } else {
            return hasChoose;
        }
    }

    public static boolean checkRoleLock(String qqId, String groupId) {
        return !"0".equals(groupId) && ROLE_LOCK.containsKey(new EntityRoleLock(qqId, groupId));
    }

    public static boolean checkRoleLock(long qqId, String groupId) {
        return !"0".equals(groupId) && ROLE_LOCK.containsKey(new EntityRoleLock(String.valueOf(qqId), groupId));
    }
}
